import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

const resolve = (dir) => {
    return path.resolve(__dirname, dir)
}

export default defineConfig(({mode}) => {
    // loadEnv(mode, process.cwd(), 'GZG_')
    return {
        envPrefix:['GZG_'],
        server:{
            host:'127.0.0.1'
        },
        build:{
            
        },
        resolve:{
            alias:{
                '@': resolve('src'),
                'styles': resolve('src/styles'),
                'layout': resolve('src/layout'),
                'utils': resolve('src/utils'),
                'views': resolve('src/views'),
                'libs': resolve('src/libs'),
                'plugin': resolve('src/plugin'),
                'services':resolve('src/services')
            }
        },
        css:{
            preprocessorOptions:{
                scss:{
                    additionalData: `@use "styles/element/index.scss" as *;`,
                }
            }
        },
        plugins:[
            vue(),
            Components({
                extensions:['vue'],
                include: [/\.vue$/, /\.vue\?vue/],
                resolvers:[
                    ElementPlusResolver({
                        importStyle:'sass'
                    })
                ],
                dts: 'src/components.d.ts',
    
            }),
            
    
        ],
    }
})